package com.rjxy.plansystemmanagement.mapper;

import com.rjxy.plansystemmanagement.entity.OrderInformation;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderMapper {
    /**
     * 查询所有订单
     * @return
     */
    @Select("select * from OrderInformation")
    List<OrderInformation> list();

    /**
     * 根据id删除订单
     * @param id
     */
    @Delete("delete from OrderInformation where id = #{id}")
    void deleteOrder(Integer id);

    /**
     * 增加订单信息
     * @param orderInformation
     */
    @Insert("insert into OrderInformation(OrderNo,OrderTime,Price,SpaceType,FlightID,UserID,BuyNum,TPrice,status)" +
            "VALUES (#{OrderNo},#{OrderTime},#{Price},#{SpaceType},#{FlightID},#{UserID},#{BuyNum},#{TPrice},#{status})")
    void addOrder(OrderInformation orderInformation);

    /**
     * 查询指定id{}的订单
     * @param id
     * @return
     */
    @Select("select * from OrderInformation where id = #{id}")
    OrderInformation getOrderById(Integer id);

    @Select("select * from OrderInformation where UserID = #{id}")
    List<OrderInformation> getOrderByUid(Integer id);

    void updateOrder(OrderInformation orderInformation);
}
